﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PMS.Utilities
{
    public static class DateTimeExtensions
    {
        public static string ToShortPattern(this DateTime? dt)
        {
            if (!dt.HasValue) { return String.Empty; }
            return dt.Value.ToShortPattern();
        }

        public static string ToShortPattern(this DateTime dt)
        {
            return dt.ToString(Utility.cultureInfo.DateTimeFormat.ShortDatePattern);
        }

        public static DateTime FirstDayOfMonth(this DateTime dt)
        {
            return new DateTime(dt.Year, dt.Month, 1);
        }

        public static DateTime LastDayOfMonth(this DateTime dt)
        {
            return new DateTime(dt.Year, dt.Month + 1, 1).AddDays(-1);
        }
    }
}
